home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C
/
Applications
/
MacGzip 1.0
/
source
/
Mac
/
MacIO.h
< prev
next >
Wrap
Text File
|
1995-08-31
|
4KB
|
174 lines
/*
* MacIO.h
* (c) SPDsoft, August 20, 1995
*/
#ifndef __FILES__
#include <Files.h>
#endif
#ifndef _MACBINARY_H_
#include "MacBinary.h"
#endif
#ifndef EFAULT
#define EFAULT ioErr
#endif
#ifndef EBADF
#define EBADF ioErr
#endif
#ifndef ENFILE
#define ENFILE tmfoErr
#endif
/*
* file table (iov)
*/
#define MIO_MAX_FILES 2 /* enaugh for macgzip */
#define MIO_BUFSIZE 4096 /* > sizeof(MBIIHeader) */
#define MIO_ASCII 0
#define MIO_BINARY 1
#define MIO_MACBIN 2
#define OM_RDONLY 0
#define OM_WRONLY 0x0001
#define OM_RDWR 0x0002
#define OM_TEXT 0x0040
#define OM_BINARY 0x0080
#define OM_MACBINARY 0x0100
typedef struct
{
int omode;
int fsomode; /* save the original open mode (mb->plain) */
int mode;
short dref,
rref;
char buffer[MIO_BUFSIZE];
long pos; /* Bytes w/r. Updated after filling buffer */
long len;
int blen; /* Lenght of buffer ('dirty') */
char *bstart; /* pointer to next free pos in buffer */
long rdlen, /* rounded start.dlen (to 128) (w) */
rrlen; /* rounded start.rlen (to 128) (w) */
int deof,
reof;
int new; /* set if a new file was created for fs */
MBIIStartHeader start;
MBIIHeader header;
FSSpec fs;
} fildes;
extern fildes fd_table[MIO_MAX_FILES]; /* for low level access */
extern int fd_busy[MIO_MAX_FILES];
extern OSType DefCreator;
extern OSType DefType;
int fs_open( FSSpec *fs, int mode, ...);
int fs_close(int fd);
int fs_unlink(FSSpec *fs);
int fs_read(int fd, char *buf, unsigned int n);
int fs_write(int fd, char *buf, unsigned int n);
/* from stat.h & sys/types, 01a,01nov94,ejo written.*/
/* this is a little dirty, but this is not a POSIX lib... */
#include <time.h>
#if defined (__MWERKS__) && !defined (_YVALS)
#include <yvals.h>
#endif
typedef short dev_t;
typedef long ino_t;
typedef unsigned long mode_t;
typedef int nlink_t;
typedef long off_t;
#ifdef __MWERKS__
#ifndef _SIZET
#define _SIZET
typedef _Sizet size_t;
#endif
#elif defined (THINK_C)
#include <size_t.h>
#else
#ifndef __size_t__
#define __size_t__
typedef unsigned int size_t;
#endif
#endif
typedef unsigned int ssize_t;
typedef int uid_t;
typedef int gid_t;
typedef int pid_t;
#define S_IFMT 0170000 /* type of file */
#define S_IFIFO 0010000 /* fifo */
#define S_IFDIR 0040000 /* directory */
#define S_IFCHR 0020000 /* character special */
#define S_IFBLK 0060000 /* block special */
#define S_IFREG 0100000 /* regular */
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISUID 0004000
#define S_ISGID 0002000
#define S_IRUSR 00400
#define S_IWUSR 00200
#define S_IXUSR 00100
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
#define S_IRGRP 00040
#define S_IWGRP 00020
#define S_IXGRP 00010
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
#define S_IROTH 00004
#define S_IWOTH 00002
#define S_IXOTH 00001
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
/* historical file modes */
#define S_IREAD 00400
#define S_IWRITE 00200
#define S_IEXEC 00100
struct stat
{
mode_t st_mode;
ino_t st_ino;
dev_t st_dev;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
/* Extra fields for MacOS */
off_t st_dsize; /* Data Fork size rounded up to 128 */
off_t st_rsize; /* Res Fork size rounded up to 128 */
off_t st_mbsize; /* 128 bytes for MacBinary Header + DF & RF both rounded up to 128 */
};
int fs_stat(FSSpec *fs, struct stat *buf);